import http from '@/utils/http'
const env = import.meta.env
const BASE_URL = env.PROD ? `${env.VITE_API_BASE_URL}/api` : '/api'
/** @desc 管理员列表 */
export function adminUserList(data: any) {
  return http.get(`${BASE_URL}/admin-user`, data)
}

/** @desc 添加管理员 */
export function adminUserAdd(data: any) {
  return http.post(`${BASE_URL}/admin-user/add`, data)
}

/** @desc 编辑管理员 */
export function adminUserEdit(data: any) {
  return http.put(`${BASE_URL}/admin-user/${data.id}`, data)
}

/** @desc 删除管理员 */
export function adminUserDelete(data: any) {
  return http.delete(`${BASE_URL}/admin-user/${data.id}`)
}

/** @desc 管理员详情 */
export function adminUserDetail(data: any) {
  return http.get(`${BASE_URL}/admin-user/${data.id}`)
}

/** @desc 管理员角色 */
export function adminUserRoles(data: any) {
  return http.get(`${BASE_URL}/admin-user/${data.id}/roles/admin`)
}

/** @desc 管理员添加角色 */
export function adminUserRolesAdd(data: any) {
  return http.put(`${BASE_URL}/admin-user/${data.id}/roles/admin`, data)
}

/** @desc 获取角色列表 */
export function roleList(data: any) {
  return http.get(`${BASE_URL}/role`, data)
}

/** @desc 添加角色 */
export function roleAdd(data: any) {
  return http.post(`${BASE_URL}/role/add`, data)
}

/** @desc 编辑角色 */
export function roleEdit(data: any) {
  return http.put(`${BASE_URL}/role/${data.id}`, data)
}

/** @desc 删除角色 */
export function roleDelete(data: any) {
  return http.delete(`${BASE_URL}/role/${data.id}`)
}

/** @desc 角色详情 */
export function roleDetail(data: any) {
  return http.get(`${BASE_URL}/role/${data.id}`)
}

/** @desc 角色权限 */
export function roleAdmin(data: any) {
  return http.get(`${BASE_URL}/role/${data.id}/permissions`)
}

/** @desc 角色添加权限 */
export function roleAdminAdd(data: any) {
  return http.post(`${BASE_URL}/role/${data.id}/permissions`, data)
}

/** @desc 获取项目下的所有角色 */
export function allRoleList() {
  return http.get(`${BASE_URL}/guard-name-roles/admin`)
}

/** @desc 修改密码 */
export function userChangePassword(data: any) {
  return http.patch(`${BASE_URL}/user-change-password`, data)
}

/** @desc 获取所有权限组 */
export function allPermissionGroupList() {
  return http.get(`${BASE_URL}/permission-group-all`)
}

/** @desc 获取权限组列表 */
export function permissionGroupList(data: any) {
  return http.get(`${BASE_URL}/permission-group`, data)
}

/** @desc 添加权限组 */
export function permissionGroupAdd(data: any) {
  return http.post(`${BASE_URL}/permission-group`, data)
}

/** @desc 编辑权限组 */
export function permissionGroupEdit(data: any) {
  return http.patch(`${BASE_URL}/permission-group/${data.id}`, data)
}

/** @desc 删除权限组 */
export function permissionGroupDelete(data: any) {
  return http.delete(`${BASE_URL}/permission-group/${data.id}`)
}

/** @desc 获取项目下的所有权限 */
export function guardNameForPermissions() {
  return http.get(`${BASE_URL}/guard-name-for-permissions/admin`)
}

/** @desc 当前用户全部权限 */
export function permissionUserAll() {
  return http.get(`${BASE_URL}/permission-user-all`)
}

/** @desc 获取角色全部权限 */
export function currentPermissions(data: any) {
  return http.get(`${BASE_URL}/role/${data.id}/permissions`)
}

/** @desc 权限列表 */
export function permission(data: any) {
  return http.get(`${BASE_URL}/permission`, data)
}

/** @desc 添加权限 */
export function permissionAdd(data: any) {
  return http.post(`${BASE_URL}/permission`, data)
}

/** @desc 编辑权限 */
export function permissionEdit(data: any) {
  return http.patch(`${BASE_URL}/permission/${data.id}`, data)
}

/** @desc 删除权限 */
export function permissionDelete(data: any) {
  return http.delete(`${BASE_URL}/permission/${data.id}`, data)
}

/** @desc 当前用户菜单 */
export function myMenu() {
  return http.get(`${BASE_URL}/my-menu`)
}

/** @desc 菜单列表 */
export function getMenu(data: any) {
  return http.get(`${BASE_URL}/menu`, data)
}

/** @desc 创建菜单 */
export function menuAdd(data: any) {
  return http.post(`${BASE_URL}/menu`, data)
}

/** @desc 编辑菜单 */
export function menuEdit(data: any) {
  return http.patch(`${BASE_URL}/menu/${data.id}`, data)
}

/** @desc 删除菜单 */
export function menuDelete(data: any) {
  return http.delete(`${BASE_URL}/menu/${data.id}`)
}
